<header class="demo-header">
    <div class="title3Left flt text-center header-small">
        <a href="javascript:history.back(-1);" class="whiteC">
            <img src="/img/back.png" class="backimg">返回
        </a>
    </div>
    <div class="title3Middle flt text-center">最新发布</div>
    <div class="title3Right flt text-center"></div>
</header>
<div class="graybg new-publish">
    <?php foreach ($this->article_list as $v) { ?>
        <div class="product-list newproduct whitebg" style="border: none;">
            <div style="padding: 15px 0 5px;" class="newreleaseborno">
                <div class="imgclass text-center" style="width: 22%;">
                    <img src="<?php echo isset($v['user_info']['headimgurl'])?$v['user_info']['headimgurl']: \Util\Config::get('onerror_img'); ?>" style="height: 50px;width: 50px;border-radius: 50%;"/>
                </div>
                <div class="flt pline" style="padding: 3px 0 0;">
                    <p class="cuxiao-font"><strong><?php echo isset($v['user_info']['nickname'])?$v['user_info']['nickname']:'未知'; ?></strong></p>
                    <p class="ellipsis product" style="width: 90%;"><?php echo $v['title']?></p>
                </div>
                <div class="fontsize fontC flt padding-top2" style="width: 18%;">
                    <?php echo $v['long_time']; ?>
                </div>
            </div>
            <a href="/article/detail/?id=<?php echo $v['id']; ?>">
                <img src="<?php echo $v['img']?>"  onerror="this.src='<?php echo \Util\Config::get('onerror_img') ?>'" class="img-width" />
                <div class="div-center header-small lineheight newreleaseborno achongtu">
                    <?php echo $v['remark']?>...
                </div>
            </a>
            <div class="big-div paddingnot border1" style="border-bottom: 0;">
                <div onclick="javascript:fabulous(this);return false;"  article_id = <?php echo $v['id']; ?>>
                    <input value="<?php if($v['fabulous_id'])echo $v['fabulous_id'];?>" type="hidden" class="fabulous_id">
                    <?php if($v['fabulous_id']) {?>
                        <img class="img" src="/img/liveclick.png" />点赞
                    <?php }else{ ?>
                        <img class="img" src="/img/live.png" />点赞
                    <?php } ?>

                </div>
                <div><a href="/active/comment"><img src="/img/comment.png"/>评论</a></div>
                <div data-id="<?php echo $v['id'];?>" onclick="shareAticle(this)"><img  src="/img/fenxiang_icon.png"/>分享</div>
                <div class="read-amount"><img src="/img/read.png"/><?php echo $v['reading_times']?></div>
            </div>
        </div>
    <?php } ?>
</div>
<script type="text/javascript">
    function fabulous(el) {
        var img = $('.img').attr("src");
        /*点赞*/
       if (img == '/img/live.png'){
           var article_id = $(el).attr('article_id');
           $.ajax({
               type: "post",
               url : "/article/fabulous",
               dataType:'json',
               data:{'article_id':article_id},
               success: function(res){
                   if (res.code == 200) {
                       $(el).children('img').attr('src','/img/liveclick.png');
                       $(el).children('input').val(res.result.fabuulous_id);
                   }
               },
               error: function(){
               }
           });
       }else{ /*取消点赞*/
           var fabulous_id = $(el).children('input').val();
           $.ajax({
               type: "post",
               url : "/article/cancel-fabulous",
               dataType:'json',
               data:{'fabulous_id':fabulous_id},
               success: function(res){
                   if (res.code == 200) {
                       $('.img').attr('src','/img/live.png');
                   }
               },
               error: function(){
               }
           });
       }
    }
</script>
